import request from "./request";
//封装登录接口
export function login(data) {//登录
    return request({
        url: "/login",
        method: 'POST',
        data
    })
}
export function menus(data) {//左侧菜单
    // console.log(data);
    return request({
        url: "/menus",
        method: 'GET',
        data
    })
}
export function users(params) {//首页列表
    return request({
        url: "/users",
        method: 'GET',
        params
    })
}
export function usersAdd(data) {//添加用户
    return request({
        url: "/users",
        method: 'POST',
        data
    })
}
export function Edituser(id, data) {//编辑
    return request({
        url: `/users/${id}`,
        method: 'PUT',
        data
    })
}
export function stateuser(uId, type, data) {//修改状态
    return request({
        url: `users/${uId}/state/${type}`,
        method: 'PUT',
        data
    })
}
export function Deleteuser(id, data) {//删除
    return request({
        url: `/users/${id}`,
        method: 'DELETE',
        data
    })
}
export function Rolelist() {//角色列表
    return request({
        url: `/roles`,
        method: 'GET',
    })
}

export function Distribution(id, data) {//分配角色给用户接口
    return request({
        url: `/users/${id}/role`,
        method: 'put',
        data
    })
}
export function Addroles(data) {//添加角色列表
    return request({
        url: `/roles`,
        method: 'POST',
        data
    })
}
export function Editroles(id, data) {//编辑角色
    return request({
        url: `/roles/${id}`,
        method: 'PUT',
        data
    })
}

export function Removeuser(id, data) {//删除角色
    return request({
        url: `/roles/${id}`,
        method: 'DELETE',
        data
    })
}

export function Permissions(list) {//所有权限列表
    return request({
        url: `/rights/${list}`,
        method: 'GET',

    })
}
export function Goodslist(params) {//商品列表
    return request({
        url: `/goods`,
        method: 'GET',
        params
    })
}
export function DeleteGoods(id) {//删除
    return request({
        url: `/goods/${id}`,
        method: 'delete',
    })
}
export function EditGoods(id, data) {//编辑提交商品
    console.log(id, data);
    return request({
        url: `/goods/${id}`,
        method: 'put',
        data
    })
}
export function deleteRoleRightsAPI(roleId, rightId) {//删除角色指定权限
    return request({
        url: `roles/${roleId}/rights/${rightId}`,
        method: 'delete'
    })
}

//调用树形权限列表接口
export function getTreeRightListsAPI() {
    return request({
        url: `rights/tree`,  //以树形权限列表形式显示
        method: 'get'
    })
}
export function setRightsToRoleAPI(roleId, data) {//当前角色权限ID
    return request({
        url: `roles/${roleId}/rights`,
        method: 'POST',
        data
    })
}
export function GoodsCategory(params) {//商品分类列表
    return request({
        url: `categories`,
        method: 'GET',
        params
    })
}
export function GoodsClassify(params) {//商品分类列表
    return request({
        url: `categories`,
        method: 'GET',
        params
    })
}
export function EditSubmit(id, data) {//编辑分类
    return request({
        url: `categories/${id}`,
        method: 'PUT',
        data
    })
}
export function DeleteClassify(id) {//商品删除
    return request({
        url: `categories/${id}`,
        method: 'delete',
    })
}
export function ConfirmClassify(data) {//确定添加分类
    return request({
        url: `categories`,
        method: 'POST',
        data
    })
}
export function ParameterListAPI(cateId, params) {//参数列表
    return request({
        url: `categories/${cateId}/attributes`,
        method: 'GET',
        params
    })
}
export function DeleteParameter(id, attrid) {//删除分类参数
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: 'delete',

    })
}
export function EditParameter(id, attrid, data) {//编辑分类参数
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: 'put',
        data
    })
}
export function AddParameter(id, data) {//添加分类参数
    return request({
        url: `categories/${id}/attributes`,
        method: 'post',
        data
    })
}
export function AddCommodity(data) {//添加商品
    return request({
        url: `goods`,
        method: 'post',
        data
    })
}
export function Orderlist(params) {//订单数据列表
    return request({
        url: `/orders`,
        method: 'GET',
        params
    })
}
export function EditOrder(id, data) {//编辑订单数据
    return request({
        url: `/orders/${id}`,
        method: 'put',
        data
    })
}
//查看流程数据接口
export function getlogisticsAPI() {
    return request({
        //真实情况下，/kuaidi/:id 其中的id是每个订单号返回的数据，这里的1106975712662只是一个测试物流
        url: "/kuaidi/1106975712662",
        method: "GET",
    });
}

export function TheLineChart(params) {//折线图
    return request({
        url: `reports/type/1`,
        method: 'get',
        params
    })
}






